<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

/**
 * @OA\Schema(
 *     schema="SchoolUserResource",
 *     title="学校用户资源",
 *     description="学校用户信息",
 *     @OA\Property(property="id", type="integer", description="用户ID", example=1),
 *     @OA\Property(property="school_id", type="integer", description="学校ID", example=1),
 *     @OA\Property(property="real_name", type="string", description="真实姓名", example="张三"),
 *     @OA\Property(property="account", type="string", description="账号", example="zhangsan"),
 *     @OA\Property(property="tel", type="string", description="联系电话", example="13800138000"),
 *     @OA\Property(property="id_card", type="string", description="身份证号", example="110101199001011234"),
 *     @OA\Property(property="enable", type="boolean", description="是否启用", example=true),
 *     @OA\Property(property="memo", type="string", description="备注", example="用户备注信息"),
 *     @OA\Property(property="created_at", type="string", format="date-time", description="创建时间", example="2025-01-01 12:00:00"),
 *     @OA\Property(property="updated_at", type="string", format="date-time", description="更新时间", example="2025-01-01 12:00:00")
 * )
 */
class SchoolUserResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'school_id' => $this->school_id,
            'real_name' => $this->real_name,
            'account' => $this->account,
            'tel' => $this->tel,
            'id_card' => $this->id_card,
            'enable' => $this->enable,
            'memo' => $this->memo,
            'created_at' => $this->created_at?->toDateTimeString(),
            'updated_at' => $this->updated_at?->toDateTimeString(),
        ];
    }
} 